<style type="text/css"></style>
<template>
  <el-dialog
    :close-on-click-modal="false"
    :visible.sync="visible"
    :width="'88%'"
    style="opacity: 0.8;background-image: url(./static/img/hotelbg.png);">
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading">
      <el-table-column
        prop="nickname"
        header-align="center"
        align="center"
        label="用户昵称">
      </el-table-column>
      <el-table-column
        prop="sex"
        header-align="center"
        align="center"
        label="性别">
         <template slot-scope="scope">
          <el-tag v-if="scope.row.sex === 1" size="small" type="primary">男
          </el-tag>
          <el-tag v-if="scope.row.sex === 2" size="small" type="primary">女</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="phone"
        header-align="center"
        align="center"
        label="电话">
      </el-table-column>
      <el-table-column
        prop="typename"
        header-align="center"
        align="center"
        label="房间类型">
      </el-table-column>
      <el-table-column
        prop="starttime"
        header-align="center"
        align="center"
        label="入住时间">
      </el-table-column>
      <el-table-column
        prop="endtime"
        header-align="center"
        align="center"
        label="离开时间">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
  </el-dialog>
</template>
<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          key: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
        userinfoid: 0
      }
    },
    methods: {
      // 获取数据列表
      init (id) {
        this.userinfoid = id
        this.visible = true
        this.getdata(this.userinfoid)
      },
      getdata (id) {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/roomreceipt/roomreceipt/checklist'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'key': this.dataForm.key
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.init()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.init()
      }
    }
  }
</script>


